


* cd "C: ... \replication files"
use replicationdata_final.dta, clear

*VECTORS
global covar male age uniedu paidwork frp refugees miss_refugees taxes 
global sescovar male age uniedu paidwork postXmalec postXagec postXunieduc postXpaidworkc
global sescovar2 male age uniedu paidwork postXmalec2 postXagec2 postXunieduc2 postXpaidworkc2
global sescovar3 male age uniedu paidwork postXmalec3 postXagec3 postXunieduc3 postXpaidworkc3
global strata oversampled_munic  Gruppe_2  Gruppe_3
global outcomes fosen_pro_sami rights imp_to_know subj_ignorance support_trc prejudice  
global outcomes_miss fosen_dk miss_rights miss_imp_to_know miss_support_trc miss_prejudice 


su $covar $outcomes  
outreg2 using "descriptives.doc", replace   sum(log)   eqkeep(N mean sd) keep($covar $outcomes)








******************************
*BALANCE TEST*****************
******************************
reg post $covar $strata, vce(hc3)
outreg2 using "balance.doc", replace dec(3)
test $covar

reg post_pure_trc $covar $strata, vce(hc3)
outreg2 using "balance.doc", append dec(3)
test $covar

reg post_demo $covar $strata, vce(hc3)
outreg2 using "balance.doc", append dec(3)
test $covar

******************************
*ATTENTION CHECK************** 
******************************
reg failed post $strata, vce(hc3)
reg failed post_pure_trc $strata, vce(hc3)
reg failed post_demo $strata, vce(hc3)

******************************
*HEARD ABOUT TRC**************
******************************
reg trc_remember post $covar $strata, vce(hc3)
iegraph post, yzero ytitle("Have heard about the TRC") basictitle("Share that have heard about about the TRC") legend(order (1 "Interviewed before the release" 2 "Interviewed after the release")) ylab(, nogrid) gray graphr(color(white)) plotregion(style(none)) legend(region(lwidth(none)))
graph export "heard_about_trc.pdf", as(pdf) replace


******************************
*EFFECTS OF TRC***************
******************************

*TABLE EFFECTS OF TRC WITHOUT INTERACTIONS
foreach y in $outcomes{
	reg `y' post_pure_trc $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice using "main_trc.tex",
b(%12.3f) style(tex) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se nomtitles nonotes nonumbers
	keep(post_pure_trc )
    varlabels (post_pure_trc "Post TRC release") 
	prehead("\begin{tabular}{l*{@M}{c}}" "\hline") 
	posthead(
	&\multicolumn{1}{c}{Fosen-case:}&\multicolumn{1}{c}{Supports}&\multicolumn{1}{c}{Important}&\multicolumn{1}{c}{TRC improves }&\multicolumn{1}{c}{}\\
	&\multicolumn{1}{c}{Supports   }&\multicolumn{1}{c}{minority}&\multicolumn{1}{c}{to learn }&\multicolumn{1}{c}{relations and}&\multicolumn{1}{c}{Prejudice}\\  
	&\multicolumn{1}{c}{sami-rights}&\multicolumn{1}{c}{rights  }&\multicolumn{1}{c}{history  }&\multicolumn{1}{c}{understanding}&\multicolumn{1}{c}{scale }\\
	\hline)
	postfoot("\hline" "\end{tabular}")
	replace;
 
#delimit cr

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice using "main_trc.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles   nonumbers
	keep(post_pure_trc )
    varlabels (post_pure_trc "Post TRC release") 
	replace;
 
#delimit cr


coefplot fosen_pro_sami rights imp_to_know support_trc prejudice, keep(post_pure_trc)  swapnames aseq eqrename(fosen_pro_sami = "Fosen injustice" rights ="Minority rights" imp_to_know ="Learn about history" support_trc= "TRC support" prejudice ="Prejudice")  xline(0, lpattern(dot))   ciopts(lpattern(dash) lcolor(black)) legend(off)  graphr(color(white)) plotregion(style(none)) color(black) grid(none) nooffsets ms(0) title("Post TRC")
graph save "main_pure_trc.gph", replace

*controls
foreach y in $outcomes{
	reg `y' post_pure_trc $covar $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd local covar Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice using "covars_trc.tex",
b(%12.3f) style(tex) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(covar strata group ymean N, fmt(0 0 0 2 0) labels ("Controls" "Strata FE" "Group FE" "Mean Y" "N"))
	se nomtitles nonotes nonumbers
	keep(post_pure_trc )
    varlabels (post_pure_trc "Post TRC release") 
	prehead("\begin{tabular}{l*{@M}{c}}" "\hline") 
	posthead(
	&\multicolumn{1}{c}{Fosen-case:}&\multicolumn{1}{c}{Supports}&\multicolumn{1}{c}{Important}&\multicolumn{1}{c}{TRC improves }&\multicolumn{1}{c}{}\\
	&\multicolumn{1}{c}{Supports   }&\multicolumn{1}{c}{minority}&\multicolumn{1}{c}{to learn }&\multicolumn{1}{c}{relations and}&\multicolumn{1}{c}{Prejudice}\\  
	&\multicolumn{1}{c}{sami-rights}&\multicolumn{1}{c}{rights  }&\multicolumn{1}{c}{history  }&\multicolumn{1}{c}{understanding}&\multicolumn{1}{c}{scale }\\
	\hline)
	postfoot("\hline" "\end{tabular}")
	replace;
 
#delimit cr

*Interactions
foreach y in $outcomes{
	reg `y' post_pure_trc postXnot_samigroup  postXhigh_presence  not_samigroup high_presence $sescovar2, vce(hc3)
	est store `y'
	estadd local covar Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice  using "interactions_trc.tex",
b(%12.3f) style(tex) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(covar ymean N, fmt(0 2 0) labels ("SES controls" "Mean Y" "N"))
	se nomtitles nonotes nonumbers
	keep(post_pure_trc  postXnot_samigroup postXhigh_presence not_samigroup high_presence)
    varlabels (post_pure_trc "Post TRC release" postXnot_samigroup "Post*Kven/Finns"  postXhigh_presence  "Post*High presence" not_samigroup "Assigned Kven/Finns"  high_presence "High presence") 
	prehead("\begin{tabular}{l*{@M}{c}}" "\hline") 
	posthead(
	&\multicolumn{1}{c}{Fosen-case:}&\multicolumn{1}{c}{Supports}&\multicolumn{1}{c}{Important}&\multicolumn{1}{c}{TRC improves }&\multicolumn{1}{c}{}\\
	&\multicolumn{1}{c}{Supports   }&\multicolumn{1}{c}{minority}&\multicolumn{1}{c}{to learn }&\multicolumn{1}{c}{relations and}&\multicolumn{1}{c}{Prejudice}\\  
	&\multicolumn{1}{c}{sami-rights}&\multicolumn{1}{c}{rights  }&\multicolumn{1}{c}{history  }&\multicolumn{1}{c}{understanding}&\multicolumn{1}{c}{scale }\\
	\hline)
	postfoot("\hline" "\end{tabular}")
	replace;
 
#delimit cr


#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice  using "interactions_trc.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(covar ymean N, fmt(0 2 0) labels ("SES controls" "Mean Y" "N"))
	se mtitles nonotes nonumbers
	keep(post_pure_trc  postXnot_samigroup postXhigh_presence not_samigroup high_presence)
    varlabels (post_pure_trc "Post TRC release" postXnot_samigroup "Post*Kven/Finns"  postXhigh_presence  "Post*High presence" not_samigroup "Assigned Kven/Finns"  high_presence "High presence") 
	replace;
 
#delimit cr


foreach y in $outcomes{
	reg `y' post_pure_trc postXnot_samigroup  postXhigh_presence  not_samigroup high_presence $sescovar2, vce(hc3)
	est store `y'
	estadd local covar Yes
	estadd ysumm, replace
}


*IV
foreach y in $outcomes{
	ivreg2 `y' (trc_remember = post_pure_trc) $strata, rf first robust 
	est store `y' 
	estadd local strata Yes
	estadd local group Yes
	estadd scalar F_stat= e(widstat) 
	estadd ysumm, replace
}

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice using "iv_trc.tex",
b(%12.3f) style(tex) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(F_stat strata group ymean N, fmt(0 0 0 2 0) labels ("Kleibergen-Paap F stat." "Strata FE" "Group FE" "Mean Y" "N"))
	se nomtitles nonotes nonumbers
	keep(trc_remember )
    varlabels (trc_remember "Has heard about TRC") 
	prehead("\begin{tabular}{l*{@M}{c}}" "\hline") 
	posthead(
	&\multicolumn{1}{c}{Fosen-case:}&\multicolumn{1}{c}{Supports}&\multicolumn{1}{c}{Important}&\multicolumn{1}{c}{TRC improves }&\multicolumn{1}{c}{}\\
	&\multicolumn{1}{c}{Supports   }&\multicolumn{1}{c}{minority}&\multicolumn{1}{c}{to learn }&\multicolumn{1}{c}{relations and}&\multicolumn{1}{c}{Prejudice}\\  
	&\multicolumn{1}{c}{sami-rights}&\multicolumn{1}{c}{rights  }&\multicolumn{1}{c}{history  }&\multicolumn{1}{c}{understanding}&\multicolumn{1}{c}{scale }\\
	\hline)
	postfoot("\hline" "\end{tabular}")
	replace;
 
#delimit cr


#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice using "iv_trc.rtf",
b(%12.3f) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(F_stat strata group ymean N, fmt(0 0 0 2 0) labels ("Kleibergen-Paap F stat." "Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles nonotes nonumbers
	keep(trc_remember )
    varlabels (trc_remember "Has heard about TRC") 
	replace;
 
#delimit cr

*Missing

foreach y in $outcomes_miss{
	reg `y' post_pure_trc $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_dk miss_rights miss_imp_to_know miss_support_trc miss_prejudice   using "miss_trc.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles   nonumbers
	keep(post_pure_trc )
    varlabels (post_pure_trc "Post TRC release") 
	replace;
 
#delimit cr

*additional outcomes

foreach y in  subj_ignorance rights2 {
	reg `y' post_pure_trc $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}

#delimit;
esttab  subj_ignorance rights2  using "addy_trc.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles   nonumbers
	keep(post_pure_trc )
    varlabels (post_pure_trc "Post TRC release") 
	replace;
 
#delimit cr






************************************
*EFFECTS OF TRC IN CONTEXT OF DEMOS*
************************************
foreach y in $outcomes{
	reg `y' post_demo $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice  using "main_demo.tex",
b(%12.3f) style(tex) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se nomtitles nonotes nonumbers
	keep(post_demo)
    varlabels (post_demo "Post TRC \& demos") 
	prehead("\begin{tabular}{l*{@M}{c}}" "\hline") 
	posthead(
	&\multicolumn{1}{c}{Fosen-case:}&\multicolumn{1}{c}{Supports}&\multicolumn{1}{c}{Important}&\multicolumn{1}{c}{TRC improves }&\multicolumn{1}{c}{}\\
	&\multicolumn{1}{c}{Supports   }&\multicolumn{1}{c}{minority}&\multicolumn{1}{c}{to learn }&\multicolumn{1}{c}{relations and}&\multicolumn{1}{c}{Prejudice}\\  
	&\multicolumn{1}{c}{sami-rights}&\multicolumn{1}{c}{rights  }&\multicolumn{1}{c}{history  }&\multicolumn{1}{c}{understanding}&\multicolumn{1}{c}{scale }\\
	\hline)
	postfoot("\hline" "\end{tabular}")
	replace;
 
#delimit cr

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice using "main_demo.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles   nonumbers
	keep(post_demo)
    varlabels (post_demo "Post TRC \& demos") 
	replace;
 
#delimit cr


coefplot fosen_pro_sami rights imp_to_know support_trc prejudice, keep(post_demo)  swapnames aseq eqrename(fosen_pro_sami = "Fosen injustice" rights ="Minority rights" imp_to_know ="Learn about history" support_trc= "TRC support" prejudice ="Prejudice")  xline(0, lpattern(dot))   ciopts(lpattern(dash) lcolor(black)) legend(off)  graphr(color(white)) plotregion(style(none)) color(black) grid(none) nooffsets ms(0) title("Post TRC & demonstrations")
graph save "main_trc_demo.gph", replace

graph combine "main_pure_trc"  "main_trc_demo.gph", xcommon
graph save "main_res.gph", replace
graph export "main_res.pdf", as(pdf) replace

*Interactions
foreach y in $outcomes{
	reg `y' post_demo postXnot_samigroup  postXhigh_presence  not_samigroup high_presence $sescovar3, vce(hc3)
	est store `y'
	estadd local covar Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice  using "interactions_demo.tex",
b(%12.3f) style(tex) starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(covar ymean N, fmt(0 2 0) labels ("SES controls" "Mean Y" "N"))
	se nomtitles nonotes nonumbers
	keep(post_demo  postXnot_samigroup postXhigh_presence not_samigroup high_presence)
    varlabels (post_demo "Post TRC \& demos" postXnot_samigroup "Post*Kven/Finns"  postXhigh_presence  "Post*High presence" not_samigroup "Assigned Kven/Finns"  high_presence "High presence") 
	prehead("\begin{tabular}{l*{@M}{c}}" "\hline") 
	posthead(
	&\multicolumn{1}{c}{Fosen-case:}&\multicolumn{1}{c}{Supports}&\multicolumn{1}{c}{Important}&\multicolumn{1}{c}{TRC improves }&\multicolumn{1}{c}{}\\
	&\multicolumn{1}{c}{Supports   }&\multicolumn{1}{c}{minority}&\multicolumn{1}{c}{to learn }&\multicolumn{1}{c}{relations and}&\multicolumn{1}{c}{Prejudice}\\  
	&\multicolumn{1}{c}{sami-rights}&\multicolumn{1}{c}{rights  }&\multicolumn{1}{c}{history  }&\multicolumn{1}{c}{understanding}&\multicolumn{1}{c}{scale }\\
	\hline)
	postfoot("\hline" "\end{tabular}")
	replace;
 
#delimit cr


#delimit;
esttab fosen_pro_sami rights imp_to_know support_trc prejudice  using "C:\Users\dyrstad\Dropbox\NTNU\Projects and proposals\TRC project\presentasjon\interactions_demo.rtf",
b(%12.3f)   starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(covar ymean N, fmt(0 2 0) labels ("SES controls" "Mean Y" "N"))
	se mtitles nonotes nonumbers
	keep(post_demo  postXnot_samigroup postXhigh_presence not_samigroup high_presence)
    varlabels (post_demo "Post TRC \& demos" postXnot_samigroup "Post*Kven/Finns"  postXhigh_presence  "Post*High presence" not_samigroup "Assigned Kven/Finns"  high_presence "High presence") 
	replace;
 
#delimit cr


*Missing

foreach y in $outcomes_miss{
	reg `y' post_demo $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}

#delimit;
esttab fosen_dk miss_rights miss_imp_to_know miss_support_trc miss_prejudice   using "miss_demo.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles   nonumbers
	keep(post_demo )
    varlabels (post_demo "Post TRC \& demos" ) 
	replace;
 
#delimit cr

*additional outcomes

foreach y in  subj_ignorance rights2 {
	reg `y' post_demo $strata, vce(hc3)
	est store `y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}

#delimit;
esttab  subj_ignorance rights2  using "addy_demo.rtf",
b(%12.3f)  starlevels(* 0.10 ** 0.05 *** 0.01)
	stats(strata group ymean N, fmt(0 0 2 0) labels ("Strata FE" "Group FE" "Mean Y" "N"))
	se mtitles   nonumbers
	keep(post_demo )
     varlabels (post_demo "Post TRC \& demos" )
	replace;
 
#delimit cr



*****************
**# ADD. FIGURES 
*****************

set scheme plotplain
global outcomes2 fosen_pro_sami rights imp_to_know support_trc prejudice  


** OLS reported in Table 1

gen xtreatment = post_pure_trc
foreach y in $outcomes2{
	reg `y' xtreatment $strata, vce(hc3)
	est store x_`y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace

}
drop xtreatment
gen xtreatment = post_demo

foreach y in $outcomes2{
	reg `y' xtreatment $strata, vce(hc3)
	est store z_`y'
	estadd local strata Yes
	estadd local group Yes
	estadd ysumm, replace
}	
drop xtreatment	
	
coefplot x_*, bylabel("Post-TRC") || z_* , bylabel("Post-TRC & -demonstrations") keep(xtreatment) ylab(1 " ") xline(0) ///
	legend(label(2 "Fosen injustice") label(4 "Minority rights") label(6 "Learn about minorities") label(8 "TRC support") label(10 "Prejudice") ///
	pos(6) ring(0) cols(3) ) ///
	msize(medium) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", ///
	cond(@pval>.05, "", ///
	string(@pval,"%9.3f")))))) ///
	mlabposition(2) mlabgap(-.5) mlabsize(small) ///
	note("N=2,126" "N=2,388")
	
graph save "maineffects.gph", replace
graph export "maineffects.pdf", as(pdf) replace
graph export "maineffects.tif", as(tif) replace




	
	
** Interactions reported in Table 2 - panel A
foreach y in $outcomes2{
	reg `y' i.post_pure_trc##not_samigroup i.post_pure_trc##high_presence $sescovar3, vce(hc3)
	margins, dydx(post_pure_trc) post at(not_samigroup=(0 1))
	est store x_sami_`y'
reg `y' i.post_pure_trc##not_samigroup i.post_pure_trc##high_presence $sescovar3, vce(hc3)
	margins, dydx(post_pure_trc) post at(high_presence=(0 1))
	est store x_highpres_`y'
}

** Interactions reported in Table 2 - panel B
foreach y in $outcomes2{
	reg `y' i.post_demo##not_samigroup i.post_demo##high_presence $sescovar3, vce(hc3)
	margins, dydx(post_demo) post at(not_samigroup=(0 1))
	est store z_sami_`y'
reg `y' i.post_demo##not_samigroup i.post_demo##high_presence $sescovar3, vce(hc3)
	margins, dydx(post_demo) post at(high_presence=(0 1))
	est store z_highpres_`y'
}

// Note: Easier to organize by treatment than by moderator; would have to use the xtreatment trick as above to organize by moderator
coefplot x_sami_*, bylabel("Post-TRC") || z_sami_* , bylabel("Post-TRC & -demonstrations") ///
	legend(label(2 "Fosen injustice") label(4 "Minority rights") label(6 "Learn about minorities") label(8 "TRC support") label(10 "Prejudice") ///
	pos(6) ring(0) cols(3) ) ///
	rename(1._at="Assigned Kven/Forest Finn" 2._at="Assigned Sámi") xline(0) ///
	msize(medium) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", ///
	cond(@pval>.05, "", ///
	string(@pval,"%9.3f")))))) ///
	mlabposition(2) mlabgap(-.5) mlabsize(small) name(sami, replace) ///
	note("N=2,126" "N=2,388")
graph save "figA2.gph", replace
graph export "figA2.pdf", as(pdf) replace
graph export "figA2.tif", as(tif) replace

	
	
	
coefplot x_highpres_*, bylabel("Post-TRC") || z_highpres_* , bylabel("Post-TRC & -demonstrations") ///
	legend(label(2 "Fosen injustice") label(4 "Minority rights") label(6 "Learn about minorities") label(8 "TRC support") label(10 "Prejudice") ///
	pos(6) ring(0) cols(3) ) ///
	rename(1._at="Low presence" 2._at="High presence") xline(0) ///
	msize(medium) ///
	mlabel(cond(@pval<.001, "***", ///
	cond(@pval<.01, "**", ///
	cond(@pval<.05, "*", ///
	cond(@pval>.05, "", ///
	string(@pval,"%9.3f")))))) ///
	mlabposition(2) mlabgap(-.5) mlabsize(small) name(highpres, replace) ///
	note("N=2,126" "N=2,388")

graph save "fig2.gph", replace
graph export "fig2.pdf", as(pdf) replace
graph export "fig2.tif", as(tif) replace




** Interactions reported in Table 2 - panel A
foreach y in $outcomes2{
reg `y' i.post_pure_trc##not_samigroup i.post_pure_trc##high_presence $sescovar3, vce(hc3)
	margins, dydx(post_pure_trc) post at(high_presence=(0 1) not_samigroup=0)
	est store x_highpres_`y'
}

** Interactions reported in Table 2 - panel B
foreach y in $outcomes2{
reg `y' i.post_demo##not_samigroup i.post_demo##high_presence $sescovar3, vce(hc3)
	margins, dydx(post_demo) post at(high_presence=(0 1)  not_samigroup=0)
	est store z_highpres_`y'
}


coefplot x_highpres_*,   swapnames aseq rename(1._at="Low presence" 2._at="High presence") eqrename(x_highpres_fosen_pro_sami = "Fosen injustice" x_highpres_rights ="Minority rights" x_highpres_imp_to_know ="Learn about history" x_highpres_support_trc= "TRC support" x_highpres_prejudice ="Prejudice")  xline(0, lpattern(dot))   ciopts(lpattern(dash) lcolor(black)) legend(off)  graphr(color(white)) plotregion(style(none)) color(black) grid(none) nooffsets ms(0) title("Post TRC")
graph save "highpres_pure_trc.gph", replace

coefplot z_highpres_*,   swapnames aseq rename(1._at="Low presence" 2._at="High presence") eqrename(z_highpres_fosen_pro_sami = "Fosen injustice" z_highpres_rights ="Minority rights" z_highpres_imp_to_know ="Learn about history" z_highpres_support_trc= "TRC support" z_highpres_prejudice ="Prejudice")  xline(0, lpattern(dot))   ciopts(lpattern(dash) lcolor(black)) legend(off)  graphr(color(white)) plotregion(style(none)) color(black) grid(none) nooffsets ms(0) title("Post TRC and demonstrations")
graph save "highpres_trc_demo.gph", replace
graph export "highpres_trc_demo.pdf",as(pdf) replace






*************
*CONJOINT****
*************

keep Respondent_Serial high_presence post post_pure_trc post_demo post_trc_demo stdalder dim* conjoint*

drop dimKjennskap* dimKombPart*

rename conjointAB1 selected1
rename conjointAB2 selected2
rename conjointAB3 selected3
rename conjointAB4 selected4
rename conjointAB5 selected5

forvalues n=1/5{
	g selectedA`n' = 1 if selected`n'==1
	replace selectedA`n' = 0 if selected`n'==2
	g selectedB`n'  = 1 if selected`n'==2
	replace selectedB`n' = 0 if selected`n'==1
}
 
drop selected1 selected2 selected3 selected4 selected5

reshape long selectedA  selectedB dimSkattA  dimFlyktA  dimMiljoA dimMinoA dimUkraA dimDistA dimSkattB dimFlyktB dimMiljoB dimMinoB dimUkraB dimDistB, i( Respondent_Serial) j(round)

foreach x in selectedA  dimSkattA  dimFlyktA  dimMiljoA dimMinoA dimUkraA dimDistA {
	 rename `x' `x'1
	 renvars `x', subst(A)
}
foreach x in selectedB dimSkattB dimFlyktB dimMiljoB dimMinoB dimUkraB dimDistB {
	 rename `x' `x'2
	 renvars `x', subst(B)
}

egen id_round = group(Respondent_Serial round)

reshape long selected dimSkatt   dimFlykt  dimMiljo  dimMino  dimUkra  dimDist, i( id_round) j(pairid) 

recode dimSkatt (1=1 "Increase taxes") (2=2 "Reduce taxes"), g(taxes)
recode dimFlykt (1=2 "More restrictive") (2=1 "No change") (3=3 "Less restrictive"), g(refugees)
recode dimMiljo (1=1 "Reneveable energy") (2=2 "Protect nature"), g(environment)
recode dimMino (1 2=2 "Indigenous rights") (3 =1 "No change") (4 5 =3 "Majority interests"), g(indigenous)
recode dimUkra (1=1 "Peace talks")(2=2 "Support Ukraine") (3=3 "Fewer sanctions"), g(ukraine)
recode dimDist (1=1 "Force mergers") (2=2 "Voluntary mergers"), g(mergers)

label variable taxes "Tax policy"
label variable refugees "Refugee policy"
label variable environment "Environmental policy"
label variable indigenous "Indigenous people's rights"
label variable ukraine "Ukraine policy"
label variable mergers "Municipality mergers"

global dimensions indigenous taxes refugees environment  ukraine mergers

conjoint selected $dimensions, est(amce) id( Respondent_Serial) graph

conjoint selected $dimensions, est(mm) subg(post) id(Respondent_Serial) graph
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post release
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_post.gph", replace
graph export "mm_post.pdf", as(pdf) replace
graph export "mm_post.tif", as(tif) replace

conjoint selected $dimensions, est(mm) subg(post_pure_trc) id(Respondent_Serial) graph
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre TRC release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post TRC release
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_post_trc.gph", replace
graph export "mm_post_trc.pdf", as(pdf) replace
graph export "mm_post_trc.tif", as(tif) replace


conjoint selected $dimensions if high_presence==0, est(mm) subg(post) id(Respondent_Serial) graph
gr_edit insert (title = .sized_textbox.new, mtextq(`"Low presence areas"') style(scheme title) ) above plotregion1 , ring(7)
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post release
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_post_lowpresence.gph", replace
graph export "mm_post_lowpresence.pdf", as(pdf) replace
graph export "mm_post_lowpresence.tif", as(tif) replace

conjoint selected $dimensions if high_presence==1, est(mm) subg(post) id(Respondent_Serial) graph
gr_edit insert (title = .sized_textbox.new, mtextq(`"High presence areas"') style(scheme title) ) above plotregion1 , ring(7)
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post release
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_post_highpresence.gph", replace
graph export "mm_post_highpresence.pdf", as(pdf) replace
graph export "mm_post_highpresence.tif", as(tif) replace



**# New conjoint figure; both treatments
conjoint selected $dimensions, est(mm) subg(post_trc_demo) id(Respondent_Serial) graph 
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre TRC release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post TRC release
gr_edit legend.plotregion1.label[3].text = {}
gr_edit legend.plotregion1.label[3].text.Arrpush Post demons.
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_post_trc.gph", replace
graph export "mm_post_trc.pdf", as(pdf) replace
graph export "mm_post_trc.tif", as(tif) replace


conjoint selected $dimensions if high_presence==1, est(mm) subg(post_trc_demo) id(Respondent_Serial) graph 
gr_edit insert (title = .sized_textbox.new, mtextq(`"High presence areas"') style(scheme title) ) above plotregion1 , ring(7)
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre TRC release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post TRC release
gr_edit legend.plotregion1.label[3].text = {}
gr_edit legend.plotregion1.label[3].text.Arrpush Post demons.
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_postboth_highpres.gph", replace
graph export "mm_postboth_highpres.pdf", as(pdf) replace
graph export "mm_postboth_highpres.tif", as(tif) replace

conjoint selected $dimensions if high_presence==0, est(mm) subg(post_trc_demo) id(Respondent_Serial) graph 
gr_edit insert (title = .sized_textbox.new, mtextq(`"Low presence areas"') style(scheme title) ) above plotregion1 , ring(7)
gr_edit legend.plotregion1.label[1].text = {}
gr_edit legend.plotregion1.label[1].text.Arrpush Pre TRC release
gr_edit legend.plotregion1.label[2].text = {}
gr_edit legend.plotregion1.label[2].text.Arrpush Post TRC release
gr_edit legend.plotregion1.label[3].text = {}
gr_edit legend.plotregion1.label[3].text.Arrpush Post demons.
gr_edit legend.style.editstyle boxstyle(linestyle(color(white))) editcopy
graph save Graph "mm_postboth_lowpres.gph", replace
graph export "mm_postboth_lowpres.pdf", as(pdf) replace
graph export "mm_postboth_lowpres.tif", as(tif) replace

